home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 039a / dbpcxl15.zip / VIDLIB.H < prev   
C/C++ Source or Header  |  1992-01-25  |  8KB  |  194 lines

  1. /* vidlib.h */
  2. #if !defined(__LARGE__) && !defined(__HUGE__)
  3. #error Wrong compiler model: must be large or huge
  4. #endif
  5.  
  6. #ifndef __VIDLIB__
  7. #define __VIDLIB__
  8.  
  9. #ifndef __STDIO_H
  10. #include <stdio.h>
  11. #endif
  12.  
  13. #define  VIDLIB_VERSION    "1.7"
  14.  
  15. #define BIOScrtmode        (*((char *)    0x00000449L))
  16. #define BIOScrtcols        (*((char *)    0x0000044aL))
  17. #define BIOScrtrows        (*((char *)    0x00000484L))
  18. #define BIOScrtpoints      (*((char *)    0x00000485L))
  19. #define BIOScrtbuflen      (*((unsigned *)0x0000044cL))
  20. #define BIOScrtstartoff    (*((unsigned *)0x0000044eL))
  21. #define BIOScursor_page1   (*((unsigned *)0x00000450L))
  22. #define BIOScursor_page1x  (*((unsigned char *)0x00000450L))
  23. #define BIOScursor_page1y  (*((unsigned char *)0x00000451L))
  24. #define BIOScrtpage        (*((char *)    0x00000462L))
  25.  
  26. #define DACSIZE            768
  27. #define DEFAULTDAC         ((char *) -1L)
  28.  
  29. #define WPlane0            0x01
  30. #define WPlane1            0x02
  31. #define WPlane2            0x04
  32. #define WPlane3            0x08
  33. #define WPlaneALL          0x0f
  34.  
  35. /******************************* Global Data **************************/
  36. #ifdef VIDLIB               /* when compiling the vidlib.c only */
  37.                char _vidinit=0;
  38.                char _olddacs[DACSIZE];
  39.       unsigned char _oldmode;
  40.       unsigned int  _screen_width;
  41.       unsigned int  _screen_length;
  42.       unsigned int  _memory_length;
  43.       char *_screen_start;
  44.       char *_screen_end;
  45.       unsigned short _background_color=0;
  46.       unsigned short _foreground_color=0x40;
  47.                char  tdbg[120];
  48.                FILE *vgadebug=NULL;
  49. #else
  50. extern          FILE *vgadebug;
  51. extern          char _vidinit;
  52. extern          char _olddacs[DACSIZE];
  53. extern unsigned char _oldmode;
  54. extern unsigned int  _screen_width;      /* in bytes */
  55. extern unsigned int  _screen_length;
  56. extern unsigned int  _memory_length;     /* in total scan lines, e.g.
  57.                                             modes 0x0e,0x10, and 0x12= 819,
  58.                                             even though a different number
  59.                                             are displayed in each */
  60.  
  61. extern    char   *_screen_start;      /* Usually 0xA0000000 */
  62. extern    char   *_screen_end;        /* actually, the first byte after
  63.                                             the displayed portion */
  64. extern      unsigned short _background_color;
  65. extern      unsigned short _foreground_color;
  66. extern         char  tdbg[135];
  67.  
  68. #endif /* endif VIDLIB */
  69.  
  70.  
  71. #ifdef __cplusplus
  72. extern "C" {        /* allow compiling in TurboC++ mode */
  73. #endif
  74.  
  75. int    Vinit(void);
  76. void   Vclose(void);
  77. void   Vrestorestate(void *savebuffer);
  78. void * Vsavestate(void *savebuffer);
  79. int    isVGA(void);             /* returns 0 if no, 1 if yes */
  80. void   Start_vgadebug(char *path);
  81. void   Close_vgadebug(void);
  82.  
  83. int   VGAmode(unsigned int mode, char *palette);   /* palette may be NULL */
  84.  
  85. int   Textmode(int lines);     /* 25, 28, 33, 40, 50 are valid */
  86. int   _select_scanline_count(int scans);
  87. int   _select_character_points(int points);
  88.  
  89. /* the following routines make use of _screen_width, _screen_length, and
  90.   _screen_start to check for logical errors, so any changing of VGA registers
  91.    that change these attributes should be reflected in these variables */
  92.  
  93.     /* area fills */
  94. int Vfill256(unsigned dx, unsigned dy, unsigned sdx, unsigned sdy,
  95.                 unsigned color);
  96.  
  97.     /* video to video copy */
  98. int Vcopy256(unsigned dx, unsigned dy,
  99.              unsigned sx, unsigned sy, unsigned sdx, unsigned sdy);
  100. int Vcopy16(unsigned dx, unsigned dy,
  101.             unsigned sx, unsigned sy, unsigned sdx, unsigned sdy);
  102.  
  103.     /* System memory to video copy */
  104. int Vdisp256(unsigned dx, unsigned dy,
  105.          char *s, unsigned sw, unsigned sl,
  106.              unsigned sx, unsigned sy, unsigned sdx, unsigned sdy);
  107. int Vdisp16(unsigned dx, unsigned dy,
  108.         char *s, unsigned sw, unsigned sl,
  109.                      unsigned sx, unsigned sy, unsigned sdx, unsigned sdy);
  110.  
  111.     /* Video to System memory copy */
  112. int Vcapt256(char *d, unsigned dw, unsigned dl,
  113.                       unsigned dx, unsigned dy,
  114.                       unsigned sx, unsigned sy, unsigned sdx, unsigned sdy);
  115. int Vcapt16(char  *d, unsigned dw, unsigned dl,
  116.                      unsigned dx, unsigned dy,
  117.                      unsigned sx, unsigned sy, unsigned sdx, unsigned sdy);
  118.  
  119.  
  120. /* low level routines */
  121. void Select_RPlane(int plane);
  122. void Select_Wmode(int mode);    /* mode ranges 0-3 for VGA */
  123. int  What_Wmode(void);
  124. void Select_WPlane(int planes);    /* planes = bit mask
  125.                                                 0=plane 0 write enable,
  126.                                                 1=plane 1, etc.  */
  127. int            SQread_reg(int reg);
  128. void           SQset_reg(int reg, int value);
  129. void           SQset_regm(int reg, int value, int bitmask);
  130. void           Vdisable_refresh(void);
  131. void           Venable_refresh(void);   /* doesn't work in text mode ? */
  132. int            GCread_reg(int reg);
  133. void           GCset_reg(int reg, int value);
  134. void           GCset_regm(int reg, int value, int bitmask);
  135. int            ACread_reg(int reg);
  136. void           ACset_reg(int reg, int value);
  137. void           ACset_regm(int reg, int value, int bitmask);
  138. #define        Vborder_color(x)    (ACset_reg(0x11, (x)))
  139. int            MOread_reg(void);
  140. void           MOset_reg(int value);
  141. void           MOset_regm(int value, int mask);
  142. int            CRTCread_reg(int reg);
  143. void           CRTCset_reg(int reg, int value);
  144. void           CRTCset_regm(int reg, int value, int bitmask);
  145. void           Vwait_vretrace(void);
  146. void           Vwait_hretrace(void);
  147. void           L40set(void); /* line drawing characters don't connect in this
  148.                                 mode */
  149. void           L33set(void);
  150. extern unsigned char EGA12set[256][12]; /* smaller (8x12) ega-like font */
  151.                                         /* used in the 33 line text mode */
  152.  
  153. void  ReadDACs(void *palette);
  154. void  WriteDACs(void *palette);
  155. int   LoadDACs(int fh, char *savearea);  /* savearea must be DACSIZE bytes */
  156. int   SaveDACs(int fh, char *savearea);
  157. void  Load_Palette(int start, int count, char *palette);
  158. int   putstty(const char *s, int color); /* uses BIOS routine */
  159. int   Vputs(const char *s); /* calls putstty(s, _foreground_color); */
  160. void  Vgotoxy(int col, int row);         /* uses BIOS routine */
  161.  
  162. /* miscellaneous utilities */
  163. void * normalize(void *); /* convert a far pointer to a huge. */
  164. char * memcpyb(char *dest, char *src, unsigned count);
  165.            /* garauntees one byte at a time, unlike memcpy, which will
  166.               attempt to copy by words if on a 286,386,486,etc. */
  167. char * memcpybr(char *dest_end, char *src_end, unsigned count);
  168.            /* same as memcpyb, except a reverse direction move (bottom to top).
  169.               Note that the pointers must be to the last byte in the area. */
  170.  
  171. #ifdef _cplusplus
  172. }
  173. #endif
  174.  
  175. /* The following macros are normally in <dos.h> on TurboC and TurboC++   */
  176. /* but get excluded if you compile with ANSI-keywords only. I'm changing */
  177. /* their definition here to better compile under ANSI compilers. */
  178.  
  179. #ifdef __STDC__
  180. #define MK_FP(seg,off)\
  181. (normalize((void *)((unsigned long)seg << 16) + (unsigned long)off))
  182.  
  183. #define FP_OFF(fp)\
  184. ((unsigned)((unsigned long)normalize(fp) & (unsigned long)0x0000ffffL))
  185.  
  186. #define FP_SEG(fp)\
  187. ((unsigned)((unsigned long)normalize(fp)>>16))
  188.  
  189. #endif
  190.  
  191.  
  192. /* endif #define __VIDLIB__ */
  193. #endif
  194.